package com.zone.vehicle.sdk.module.superapp.vehicle;

import android.util.Log;

import com.zone.soa.digitalzonestore.DigitalZoneStoreProxy;
import com.zone.soa.digitalzonestore.DigitalZoneStoreProxyListener;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class SuperAppVehicleServiceManager {

    private static final String TAG = SuperAppVehicleServiceManager.class.getSimpleName();

    List listeners = new ArrayList();

    private static SuperAppVehicleServiceManager instance;
    /*
     * icm
     * */
    Timer timer = new Timer();
    private static final int DELAY = 1000;

    private SuperAppVehicleServiceManager(){

    }

    public synchronized static SuperAppVehicleServiceManager getInstance(){
        if (instance == null){
            instance = new SuperAppVehicleServiceManager();
        }
        return instance;
    }

    void startService(Object listener){
        if (listener instanceof DigitalZoneStoreProxyListener){
            DigitalZoneStoreProxy m_proxy = new DigitalZoneStoreProxy("/vendor/etc/sovp/com.shangqi.digitalstorecar");
//            m_proxy.registerListener(listener);
            timer.schedule(new TimerTask() {
                @Override
                public void run() {
                    Log.e(TAG, "run:startFindService");
                    int result = m_proxy.startFindService(DigitalZoneStoreProxy.INSTANCE_NAME_1);
                    Log.e(TAG, "findStoreService6: result:" + result);
                    if (result != 0) {
                        m_proxy.localAreaCheckResult(1, 2);
                    }
                }
            }, DELAY, DELAY);
        }
    }

}
